<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>VAL_TABLE 解析测试</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; }
        .error { color: red; font-weight: bold; }
        .success { color: green; font-weight: bold; }
        .warning { color: orange; }
        .test-content { background: #f5f5f5; padding: 10px; border-radius: 5px; margin: 10px 0; }
        pre { background: #f9f9f9; padding: 10px; border: 1px solid #ddd; overflow-x: auto; }
    </style>
</head>
<body>
    <h1>VAL_TABLE 解析测试</h1>
    
    <div class="test-content">
        <h3>测试用例：最小的 VAL_TABLE DBC</h3>
        <pre id="test-dbc-content">VERSION ""

NS_ : 
	BS_

BU_:

VAL_TABLE_ vt_BooleanValues 1 "true" 0 "false" ;

BO_ 100 TestFrame: 8 Vector__XXX
 SG_ TestSignal : 0|8@1+ (1,0) [0|255] "" Vector__XXX</pre>
    </div>

    <button onclick="testParsing()">测试解析</button>
    
    <div id="result"></div>

    <script src="dbc-parser.js"></script>
    <script>
        function testParsing() {
            const content = document.getElementById('test-dbc-content').textContent;
            const resultDiv = document.getElementById('result');
            
            try {
                console.log('开始解析测试 DBC...');
                const database = parseDBCContent(content, 'test-val-table.dbc');
                
                resultDiv.innerHTML = `
                    <div class="success">✓ 解析成功！</div>
                    <h3>解析结果：</h3>
                    <p><strong>帧数量：</strong> ${database.frames.length}</p>
                    <p><strong>警告数量：</strong> ${database.warnings.length}</p>
                    <div class="warnings">
                        <h4>警告信息：</h4>
                        ${database.warnings.map(w => `<div class="warning">行 ${w.line}: ${w.message}</div>`).join('')}
                    </div>
                `;
            } catch (error) {
                console.error('解析失败:', error);
                resultDiv.innerHTML = `<div class="error">✗ 解析失败: ${error.message}</div>`;
            }
        }
    </script>
</body>
</html> 